<?php
$this->title = "My Books";
$this->headTitle($this->title);
?>
<p><a href="<?php
    echo $this->url(array('controller' => 'index',
        'action' => 'add'));
    ?>">Add new book</a></p>
<table border="0" cellpadding="0" cellspacing="20">

    <?php $count = 1; ?>
    <?php foreach ($this->books as $book) : ?>
        <?php
        if ($count % 4 == 1) {
            echo "<tr>";
        }
        ?>

        <td>
            <?php echo "<img src='/PictureBook/" . $this->escape($book->image) . "' width='100' height='160' />"; ?><br>
            <b>Title: </b><?php echo $this->escape($book->title); ?><br>
            <b>Author: </b><?php echo $this->escape($book->author); ?><br>
            <a href="<?php
            echo $this->url(array('controller' => 'index',
                'action' => 'edit', 'id' => $book->id));
            ?>">Edit</a>
            <a href="<?php
            echo $this->url(array('controller' => 'index',
                'action' => 'delete', 'id' => $book->id));
            ?>">Delete</a>
        </td>
        <?php
        if ($count % 4 == 0) {
            echo "</tr>";
        }
        $count++;
        ?>
    <?php endforeach; ?>
        <tr><td colspan="4"><?php echo $this->paginationControl($this->books, 'Sliding', 'paging.phtml'); ?></td></tr>
</table>

